$(function () {
    $("#xsd_cbjgtz_xsdmx_table").edatagrid({
        url: $.webPath() + '/xsgl/xsdgl/xsdgl_xsmx?xsdId=' + $("#xsd_cbjgtz_tabs input[name='xsd.id']").val(),
        width: 1700,
        fitColumns: false,
        singleSelect: true,
        fit: true,
        showFooter: true,
        rownumbers: true,
        columns: [
            [
                {field: 'wzgg.code', title: '物资编码', width: 150, align: 'center'},
                {field: 'wzgg.name', title: '物资名称', width: 100, align: 'center'},
                {field: 'wzgg.ggxh', title: '规格型号', width: 100, align: 'center'},
                {field: 'wzgg.th', title: '图号', width: 50, align: 'center'},
                {field: 'ck', title: '长宽', width: 50, align: 'right'},
                {field: 'wzgg.dw', title: '单位', width: 50, align: 'center'},
                //{field: 'cd.z', title: '产地', width: 50},
                {field: 'jzfs.z', title: '记重方式', width: 50, align: 'center'},
                {field: 'kh.khbm', title: '卡号', width: 120, align: 'center'},
                {field: 'xscb', title: '销售成本(元)', width: 120, align: 'right',editor:{type:'numberbox',options:{min:0,precision:4}}, formatter: function (value) {
                    var sl = formatSlForHtml(value, ",");
                    return sl;
                }},
                {field: 'js', title: '件数', width: 50, align: 'right'},
                {field: 'sbsl', title: '数量', width: 100, align: 'right',
                    formatter: function (value) {
                        var sl = formatSlForHtml(value, ",");
                        return sl;
                    }},
                {field: 'hsj', title: '含税价(元)', width: 150, align: 'right',
                    formatter: function (value) {
                        var sl = formatJeForHtml(value);
                        return sl;
                    } },
                {field: 'hse', title: '含税额(元)', width: 150, align: 'right',
                    formatter: function (value) {
                        var sl = formatJeForHtml2(value);
                        return sl;
                    } },
                {field: 'bhsj', title: '不含税价(元)', width: 150, align: 'right',
                    formatter: function (value) {
                        var sl = formatJeForHtml(value);
                        return sl;
                    } },
                {field: 'bhse', title: '不含税额(元)', width: 150, align: 'right',
                    formatter: function (value) {
                        var sl = formatJeForHtml2(value);
                        return sl;
                    } }
            ]
        ],
        loadFilter: function (data) {
            $.each(data.rows, function () {
//                var bhsj = Math.round(this.bhsj * 10000) / 10000;
//                var hsj = Math.round(this.hsj * 10000) / 10000;
//                var sl = Math.round(this.sbsl * 10000) / 10000;
                if (this.hsj) {
                    this.hse = Math.round(multiply(this.sbsl, this.hsj) * 100) / 100;
                }
                if (this.bhsj) {
                    this.bhse = Math.round((this.hse / (1 + $("#xsd_cbjgtz_tabs input[name='xsd.sl']").val()/100)) * 100) / 100;
                }
            })
            return data;
        },
        onLoadSuccess: function () {
            $(".datagrid-htable .datagrid-cell").css('text-align', 'center');
        }
    })
});

